#ifndef _SPUPROGRAM_H
#define _SPUPROGRAM_H

#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <elf.h>
#include <malloc_align.h>

#include <csp_shared_types.h>


using namespace std;
class SpuProgram
{
public:
	SpuProgram(){};
	SpuProgram(string path, string mnemonic_);
	~SpuProgram();
	void CopyToProcess(pcb_t *proc, unsigned char ls_mem_slot);
	char* GetMnemonic(){return mnemonic;}
	int next_slot;
private:
	uint32_t _run_symtab(Elf32_Ehdr *ehdr, Elf32_Shdr *sh, char *needle);
	uint32_t find_symbol(void *elf_image, char *symbol);
	void read_spu_elf(char *filename, int slot);
	void read_spu_raw_binary(char *filename);
	ea_addr_t img_;
	ls_size_t size_;
	char* mnemonic;
	char* path;

	pcb_t init_data[MAX_SPU_SLOTS];

};

#endif
